



//
//  topview.swift
//  mywei
//
//  Created by myd on 15/12/20.
//  Copyright © 2015年 myd1. All rights reserved.
//

import UIKit

class topview: UIView {

    lazy var vi :UIView =  {
   let  vi = UIView()
        vi.backgroundColor = UIColor(white: 0.75, alpha: 1)
        return vi
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
       prepareUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func prepareUI()
    {
        addSubview(vi)
        addSubview(handimage)
        addSubview(username)
        addSubview(soure)
        addSubview(time)
        addSubview(verified)
        addSubview(vip)
        
       
        vi.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSizeMake(UIScreen.mainScreen().bounds.width,10), offset: CGPoint.zero)
        handimage.ff_AlignInner(type: ff_AlignType.TopLeft, referView: vi, size: CGSizeMake(35, 35), offset: CGPointMake(8, 18))
        username.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: handimage, size: nil, offset: CGPointMake(8, 0))
        time.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: handimage, size: nil, offset: CGPointMake(8, 0))
        vip.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: username, size: CGSizeMake(17, 17), offset: CGPointMake(8, 0))
        verified.ff_AlignInner(type: ff_AlignType.BottomRight, referView: handimage, size: CGSizeMake(17, 17), offset: CGPointMake(8.5, 8.5))
    }

    
    var data : homeweimessage?  {
        didSet
        {
           if let handim = data?.users?.profile_image_url{
           let url = NSURL(string: handim)
            handimage.sd_setImageWithURL(url, placeholderImage: UIImage(named: "avatar"))
            }
            
            
            
            username.text = data?.users?.screen_name
            time.text = "刚刚"
            
            vip.image = data?.users?.vipimage
            verified.image = data!.users?.verifiedimage
            
            }}
    
    
 
    
    
    
    
    
    
   private lazy var handimage : UIImageView = UIImageView(image: UIImage(named: "avatar"))
   private  lazy var vip : UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_expired"))
   private  lazy var verified = UIImageView(image: nil)
    
    
    
   private lazy var username : UILabel = {
   let lab = UILabel()
        lab .font = UIFont.systemFontOfSize(14)
        lab.tintColor = UIColor.darkGrayColor()
        return lab
    }()
    
   private lazy var soure : UILabel = {
   let lab = UILabel()
        lab.font = UIFont.systemFontOfSize(9)
        lab.textColor = UIColor.lightGrayColor()
        return lab
    }()
    
    
   private lazy var time : UILabel = {
   let lab = UILabel()
    lab.font = UIFont.systemFontOfSize(9)
        lab.textColor = UIColor.orangeColor()
    
        return lab
    }()
}
